package services;

import gui.LoginPanel;
import gui.VentanaAdministradorTorre;

import javax.swing.JDialog;
import javax.swing.JFrame;

import com.framework.gui.GuiUtilities;
import com.framework.util.FileUtilities;

public class CargarLoginPanel {
	
	public void cargarLogin(){
		LoginPanel lg = new LoginPanel();
		try {
			FileUtilities.readIniFile("c:/_Distribuidora/App.ini");
			// Cargo el driver en memoria
			Class.forName(System.getProperty("driver"));	
			
			
			//VentanaAdministradorTorre frame = new VentanaAdministradorTorre();
			
			
			LoginPanel panel = new LoginPanel();
			JDialog loginDialog = new JDialog(new JFrame(), "Login de usuario");
			loginDialog.getContentPane().add(panel);
			loginDialog.setModal(true);
			loginDialog.setSize(panel.getSize());
			GuiUtilities.centerWindow(loginDialog);
			loginDialog.setVisible(true);
			
			if(panel.isLoginOk()){
				VentanaAdministradorTorre frame = new VentanaAdministradorTorre();
				System.out.println("Login correcto......");
				frame.setSize(350, 300);
				GuiUtilities.centerWindow(frame);
				frame.setVisible(true);
			}
			else {
				System.err.println("Login incorrecto....");
				System.exit(0);
			}	
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}

	}

}
